import request from '@/utils/request/request';
import requestForFile from '@/utils/request/requestForFile';

// 采购订单编制 - 列表查询
export function getPmsOrderPage(params: any) {
  return request.get('/api/procurement/order/order/page', {
    params,
  });
}

// 采购订单编制 - 详情
export function getPmsOrderInfo(id: string) {
  return request.get(`/api/procurement/order/order/${id}`);
}
// 采购订单编制 - 新增
export function saveOrder(data: any) {
  return request.post('/api/procurement/order/order', data);
}
// 采购订单编制 - 修改
export function eidtOrder(data: any) {
  return request.put('/api/procurement/order/order', data);
}
// 采购订单编制 - 提交审批
export function orderApproval(id: string) {
  return request.post(`/api/procurement/order/order/approval/${id}`);
}
// 采购订单编制 - 订单签订
export function orderSigning(data: any) {
  return request.post('/api/procurement/order/order/orderSigning', data);
}
// 采购订单编制 - 正文修改
export function updateOrderBodyText(data: any) {
  return request.put('/api/procurement/order/order/updateOrderBodyText', data);
}
// 采购订单编制 - 订单签订撤销
export function orderSigningRevoke(data: any) {
  return request.post('/api/procurement/order/order/signingRevoke', data);
}
// 采购订单编制 - 删除
export function delOrderById(id: string) {
  return request.delete(`/api/procurement/order/order/${id}`);
}
// 采购订单编制 - 明细 - 列表查询
export function getPmsOrderDetailPage(params: any) {
  return request.get('/api/procurement/order/order-detail/page', {
    params,
  });
}
// 采购订单编制 - 明细 - 保存
export function saveOrderDetail(data: any) {
  return request.post('/api/procurement/order/order-detail', data);
}
// 采购订单编制 - 明细 - 批量保存
export function saveOrderDetailAll(data: any) {
  return request.post('/api/procurement/order/order-detail/saveAll', data);
}
// 采购订单编制 - 明细 - 修改
export function editOrderDetail(data: any) {
  return request.put('/api/procurement/order/order-detail', data);
}
// 采购订单编制 - 明细 - 批量修改
export function editOrderDetailAll(data: any) {
  return request.put('/api/procurement/order/order-detail/updateAll', data);
}
// 采购订单编制 - 明细 - 删除
export function delOrderDetail(id: string) {
  return request.delete(`/api/procurement/order/order-detail/${id}`);
}
// 采购订单编制 - 明细 - 导出到Excel
export function delOrderDetailExport(params: any) {
  // 文件导出接口要用专门的requestForFile，且要求responseType为blob才行
  return requestForFile.get('/api/procurement/order/order-detail/export', {
    responseType: 'blob',
    params,
  });
}
// 采购订单编制 - 附件列表
export function getPmsOrderFileList(params: any) {
  return request.get('/api/procurement/order/order-attachment/list', {
    params,
  });
}
// 采购订单编制 - 附件保存
export function saveOrderFile(data: any) {
  return request.post('/api/procurement/order/order-attachment', data);
}
// 采购订单编制 - 附件删除
export function delOrderFile(id: string) {
  return request.delete(`/api/procurement/order/order-attachment/${id}`);
}
// 获取合同类型树结构
export function getTree(params: any) {
  return request.get('/api/procurement/contract/classify/tree', {
    params,
  });
}
// 合同 - 明细 - 列表查询
export function getContractDetailPage(params: any) {
  return request.get(
    '/api/procurement/contract/maindetail/selectContractDetailIncludeChanged',
    {
      params,
    }
  );
}
// 合同 - 模板 - 详情查询
export function getTemplateInfo(id: string) {
  return request.get(`/api/procurement/contract/template/${id}`);
}
